package cn.liuyang.tinyioc.aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * Created by liuyang on 2018/4/10.
 */
public class TimerMethodInterceptor implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        System.out.println("method " + methodInvocation.getMethod() + " is called on " +
                methodInvocation.getThis() + " with args " + methodInvocation.getArguments());
        Object obj = methodInvocation.proceed();
        System.out.println("method " + methodInvocation.getMethod() + " returns " + obj);
        return obj;
    }
}
